package FileAndRecurison.递归;

import java.io.File;

/*
需求:
    在/Users/ivy/Documents/java/mydir目录下有文件和文件夹，使用递归将其输出
*/
public class RecurionsTest04文件树 {
    public static void main(String[] args) {
        printDir("/Users/ivy/Documents/java/mydir");

/*

        File file = new File("/Users/ivy/Documents/java/mydir");
        File[] files = file.listFiles();
        for (File file1 : files){
            System.out.println(file1);
        }
       for (File file1 : files) {
            if (file1.isDirectory()) {
                System.out.println(file1.toString());
            } else {
                System.out.println(file1);;
            }
        }
*/

    }

    private static void printDir(String s) {
        File file = new File(s);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isDirectory()) {
                System.out.println("├──" + "📁" + file1);
                printDir(file1.toString());
            } else {
                System.out.println("├──" + file1);
            }
        }

    }
}
